<template>
    <div class="home-product">
        <div class="page-center">
            <div class="product-section clearfix">
                <div class="left-section">
                    <div class="swiper-container swiper-home-product">
                        <div class="swiper-wrapper">
                            <div class="swiper-slide" v-for="(item, index) in slides" :key="index">
                                <div class="product-card">
                                    <a :href="`/product-detail?id=${item.id}`">
                                        <img :src="item.imageUrl" :alt="item.name" />
                                        <h3 class="title">{{ item.name }}</h3></a
                                    >
                                    <div class="details">
                                        <p>货号：{{ item.productId }} CAS号：{{ item.casNo }}</p>
                                        <p>分子式：{{ item.formula }} 分子量：{{ item.molecularWeight }}</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="right-section">
                    <div class="title clearfix">
                        <h2>最新产品</h2>
                        <span></span>
                        <span></span>
                    </div>
                    <p class="desc">
                        实验室团队具有丰富的有机合成经验，精通不同类型的杂质项目合成与制备，时时更新最新产品目录
                    </p>
                    <div class="swiper-prev-next">
                        <div class="button" @click="priveSlide"><i class="fa fa-arrow-left"></i></div>
                        <div class="button" @click="nextSlide"><i class="fa fa-arrow-right"></i></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import Swiper from 'swiper'
import 'swiper/dist/css/swiper.min.css'

const slides = [
    {
        id: 1,
        name: '依托考昔杂质14',
        imageUrl: 'https://www.sincopharmachem.com.cn/Images/product/A18443.jpg',
        productId: 'E02291',
        casNo: '855307-79-8',
        formula: 'C18H13ClN2O2S',
        molecularWeight: '356.82',
    },
    {
        id: 2,
        name: '依托考昔杂质15',
        imageUrl: 'https://www.sincopharmachem.com.cn/Images/product/A18443.jpg',
        productId: 'E02291',
        casNo: '855307-79-8',
        formula: 'C18H13ClN2O2S',
        molecularWeight: '356.82',
    },
    {
        id: 3,
        name: '依托考昔杂质16',
        imageUrl: 'https://www.sincopharmachem.com.cn/Images/product/A18443.jpg',
        productId: 'E02291',
        casNo: '855307-79-8',
        formula: 'C18H13ClN2O2S',
        molecularWeight: '356.82',
    },
    {
        id: 4,
        name: '依托考昔杂质17',
        imageUrl: 'https://www.sincopharmachem.com.cn/Images/product/A18443.jpg',
        productId: 'E02291',
        casNo: '855307-79-8',
        formula: 'C18H13ClN2O2S',
        molecularWeight: '356.82',
    },
    {
        id: 5,
        name: '依托考昔杂质18',
        imageUrl: 'https://www.sincopharmachem.com.cn/Images/product/A18443.jpg',
        productId: 'E02291',
        casNo: '855307-79-8',
        formula: 'C18H13ClN2O2S',
        molecularWeight: '356.82',
    },
]
const homeProductSwiper = ref(null)

onMounted(() => {
    homeProductSwiper.value = new Swiper('.swiper-home-product', {
        slidesPerView: 3,
        slidesPerGroup: 1,
        slidesBetween: 0,
        loop: true,
        autoplay: 2000,
    })
})

const priveSlide = () => {
    homeProductSwiper.value.slidePrev()
}
const nextSlide = () => {
    homeProductSwiper.value.slideNext()
}
</script>
<style lang="scss" scoped>
.home-product {
    height: 596px;
    padding: 50px 0;
    background: #f7f7f7;
}

.product-section {
    .left-section {
        width: 75%;
        float: left;

        .product-card {
            height: 496px;
            border-right: 1px solid #eee;
            padding: 30px 15px;
            background: #fff;
            transition: all 0.3s;
            margin-bottom: 50px;

            &:hover {
                border-color: rgb(0, 167, 225);
                img {
                    transform: scale(1.1);
                }
            }

            img {
                width: 100%;
                height: auto;
                display: block;
                margin-bottom: 10px;
            }

            .contact-info {
                margin: 10px 0;
                color: #999;
                font-size: 12px;
                text-align: center;

                span {
                    margin-right: 15px;
                }
            }

            .title {
                margin: 10px 0;
                color: #0d87dc;
                text-align: center;
                font-size: 16px;
                line-height: 1.4;
            }

            .details {
                color: #666;
                font-size: 14px;
                line-height: 1.6;

                p {
                    margin: 5px 0;
                }
            }
        }
    }

    .right-section {
        width: 25%;
        float: right;
        padding: 30px 30px 0 20px;
        h2 {
            letter-spacing: 4px;
            color: #000;
            font-size: 32px;
            margin-bottom: 15px;
        }
        .title {
            span {
                width: 70px;
                float: left;
                display: inline-block;
                transition: all 0.5s;
                height: 5px;
                &:first-of-type {
                    background: #0d87dc;
                    height: 5px;
                    margin-right: 2px;
                }
                &:last-child {
                    background: #993b2f;
                    height: 5px;
                }
            }
        }
        &:hover {
            .title {
                span {
                    width: 50px;
                }
            }
        }
        .swiper-prev-next {
            .button {
                background: #efefef;
                height: 40px;
                width: 40px;
                border-radius: 100px;
                line-height: 40px;
                text-align: center;
                float: left;
                cursor: pointer;
                margin-right: 10px;
                &:hover {
                    background: #0d87dc;
                    color: #fff;
                }
            }
        }

        .desc {
            margin: 15px 0;
            font-size: 14px;
            color: #666;
        }
    }
}
</style>
